#!/bin/bash

echo "=== 测试后端API ==="

# 登录获取token
echo "1. 登录获取token..."
LOGIN_RESPONSE=$(curl -s -X POST http://127.0.0.1:8000/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username":"liuhui","password":"123456"}')

echo "登录响应: $LOGIN_RESPONSE"

# 提取token
TOKEN=$(echo $LOGIN_RESPONSE | grep -o '"token":"[^"]*"' | cut -d'"' -f4)
echo "Token: $TOKEN"

# 测试basic_data接口
echo ""
echo "2. 测试basic_data接口..."
curl -s -H "Authorization: Bearer $TOKEN" \
  http://127.0.0.1:8000/api/customer/customer/basic_data | jq '.'

echo ""
echo "=== 测试完成 ==="
